{% extends "djanet.html" %}

{#
 - $Id: home.html 7557b5d4d82b 2012/12/02 09:07:16 pgurumur $
 - Copyright (c) 2009 Prabhu Gurumurthy  <pgurumur@gmail.com>
 - 
 - Permission to use, copy, modify, and distribute this software for any
 - purpose with or without fee is hereby granted, provided that the above
 - copyright notice and this permission notice appear in all copies.
 -
 - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#}

{# $Revision: 7557b5d4d82b $ #}
{# $Author: pgurumur $ #}
{% block djanet_script %}
<script type = "text/javascript">
   {% url djanet.views.djanet_getmask as getmask %}
   $("#randstr").attr("size", "40");
   $("#length").val("12");
   $("#getmask").click(function() {
         var masklen = $("#masklen").val();
         var maskopt = $("#maskopt").val();
         $.post("{{ getmask }}", { length: masklen, type: maskopt },
            function(data, textstatus) { 
               if (data.success == true) {
                  $("#maskval").val(data.netmask);
               }
               else {
                  jQuery.error(data.error);
               }
            }, "json");

         return false;
      }
   );       

   $("#clrmask").click(function() {
         $("#masklen").val("");
         $("#maskopt").val(0);
         $("#maskval").val("");
         return false;
      }
   );

</script>

{% endblock %}

{% block djanet_body %}

<div id = "tabs">
   <ul>
      <li><a href = "#tabs-1">{% block tabtitle %}{% endblock %}</a></li>
      <li><a href = "#tabs-2">Utilities</a></li>
   </ul>

   <div id = "tabs-1">
      {% block djanet_content %}{% endblock %}
      {% block djanet_content_script %} {% endblock %}
   </div>
   <div id = "tabs-2">
      {% url djanet.views.djanet_getmask as getmask %}
      <hr/>
      <div id = "randstrform" title = "Generate Random String">
         <h2> Generate Random String </h2>
         <form>
            <p class = "validateTips">Length is required!</p>
            <fieldset>
               <label for = "Length">Length: </label>
               <input type = "text" name = "length" id = "length"
               class = "text ui-widget-content ui-corner-all" />
               <label for = "String">String: </label>
               <input type = "text" name = "string" id = "randstr"
               class = "text ui-widget-content ui-corner-all" />
               <p>
                 <button id = "generate">Generate</button>
                 <button id = "clrstr">Clear</button>
               </p>
            </fieldset>
         </form>
      </div>
      <hr/>
      <div id = "netmaskform" title = "Netmask/Wildcard">
         <h2> Generate Netmask/Wildcard </h2>
         <form id = "maskform">{% csrf_token %}
            <fieldset>
               <label for = "masklen">Length: </label>
               <input type = "text" autocomplete = "off" id= "masklen"/>
               <label for = "maskopt">Type: </label>
               <select id = "maskopt" name = "maskopt">
                  <option value = "0">WildCard</option>
                  <option value = "1">NetMask</option>
               </select>
               <label for = "maskval">Value: </label>
               <input type = "text" id = "maskval"/>
               <p>
                  <button id = "getmask">GetMask</button>
                  <button id = "clrmask">Clear</button>
               </p>
            </fieldset>
         </form>
      </div>
   </div>
</div>

{% endblock %}
